[NO-REF] - update PIA module with guard/prefilter/fmtOptions - #484
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Product Insights Agent (PIA) client to support additional request/query parameters used for experiments and response formatting, and aligns the public TypeScript types and module tests with the new capabilities.
Changes:
- Add support in PIA URL construction for
testCells(asef-*query params) and additional request parameters:features,feature_variants,pre_filter_expression,guard, andfmt_options. - Extend
pia.d.tsparameter types via a sharedPiaBaseParametersand add typing forpreFilterExpressionandfmtOptions. - Add/extend PIA module specs to cover newly supported parameters.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/types/pia.d.ts |
Extends PIA parameter typings (base params + new fields like preFilterExpression / fmtOptions). |
src/modules/pia.js |
Adds query param wiring for experiments (testCells) and new PIA request parameters. |
spec/src/modules/pia.js |
Adds tests for the new query parameter behaviors (needs stronger assertions/coverage). |
Suppressed comments (1)
spec/src/modules/pia.js:332
- For parity with other tests in this file, the new
featurestest should assert the parsed value (not just the key), andfmtOptionsbehavior is currently untested despite being added to the request builder.
it('Should pass features as query parameters when provided', function () {
this.timeout(10000);
const features = { pia_v2: true };
const { agent: { pia } } = new ConstructorIO({
apiKey: piaApiKey,
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| return pia.getSuggestedQuestions(validItemId, { featureVariants }).then(() => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(requestedUrlParams).to.have.property('feature_variants'); |
| it('Should pass pre_filter_expression as a query parameter when provided', () => { | ||
| const preFilterExpression = { brand: 'apple' }; | ||
| const { agent: { pia } } = new ConstructorIO({ | ||
| apiKey: piaApiKey, | ||
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| return pia.getSuggestedQuestions(validItemId, { preFilterExpression }).then(() => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(requestedUrlParams).to.have.property('pre_filter_expression'); | ||
| }); | ||
| }); | ||
|
|
| return pia.getSuggestedQuestions(validItemId, { features }).then(() => { | ||
| const requestedUrlParams = helpers.extractUrlParamsFromFetch(fetchSpy); | ||
|
|
||
| expect(requestedUrlParams).to.have.property('features'); |
| export interface PiaBaseParameters { | ||
| threadId?: string; | ||
| variationId?: string; | ||
| features?: Record<string, boolean>; |
There was a problem hiding this comment.
We typically don't expose features and featureVariants and we use qsParam instead whenever there's a need, since they're kind of internal, mostly used for debugging and not standardized params that we need to maintain moving forward
No description provided.